<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>参与人员详细信息</title>
<%@ include file="/common/meta.jsp"%>
<script type="text/javascript"
	src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res}/js/validate/irisvalidator.js"></script>
<script type="text/javascript"
	src="${res}/js/autodisckey/autodisckey.js"></script>

<style type="text/css">
.input_width {
	width: 130px
}

.select_width {
	width: 143px
}

.table_td td {
	border: 0
}

.long_input {
	width: 642px
}

.selectWidth4 {
	width: 624px;
}
</style>
<script type="text/javascript">
	var type = "${param.type}";
	var parentTable = parent.$("#" + "${param.parentTab}"); //父页面的表格
	var selectRadio = $(); //父页面选中的单选框
	var selectTr = $(); //父页面选中的行

	if (type == "edit") {
		selectRadio = parentTable.find(":radio:checked");
		selectTr = selectRadio.parents("tr");
	}

	$(function() {
		$("#fragment-tab1 :text,#fragment-tab1 [type='date']").addClass("input_width");
		$("#fragment-tab1 select").addClass("select_width");

		var submitpsn = selectTr.find("[name$='submit_psn']");//标示是否是申报人
		var isAdminor = false;//根据权限判断是否是单位管理员
		<security:authorize ifAnyGranted="A_DAILU_PROPOSAL">
		isAdminor = true;
		</security:authorize>

		if (type == "edit") {

			$("input:not(:radio:button),textarea").each(function() {

				var id = $(this).attr("name");
				if (id == null || id == "")
					return true;
				var parentObj = selectTr.find("[name$='/" + id + "']");
				var value = "";
				if (parentObj.is("span"))
					value = parentObj.text();
				else
					value = parentObj.val();
					if(id=="project_start_date")
						$("#start_date").val(value);
					if(id=="project_end_date")
						$("#end_date").val(value);
					else
				//if($(this).is("input"))//初始化input框 不包括radio
					$(this).val(value);
			});

			$(":radio").each(function() {//初始化radio框
				var name = $(this).attr("name");

				var value = $("[name='trade_" + name + "']").val();
				if ($(this).val() == value)
					$(this).attr("checked", true);

			});

			tree();
			changeCardType();

			if (submitpsn.length > 0 && submitpsn.val() == "1") {//如果是申报人
				//如果不是单位管理员
				if (!isAdminor) {
					$("input,select").each(function() {
						if (!$(this).attr("class") || $(this).attr("class").indexOf("notdisabled") == -1)
							$(this).attr("disabled", "true");
					});
					$("#submit_psn_note").show();//如果是项目负责人，显示如何修改个人信息提示

					$("span[name='req_submitpsn']").show();//“通讯地址”申请人为必填
					$("input[name='address']").addClass("required");

					$("a,img").removeAttr("onclick");

					parent.$("#TB_ajaxWindowTitle").html("编辑申请人信息");
				} else {
					parent.$("#TB_ajaxWindowTitle").html("设置项目负责人");
					$("input[name='zh_name']").attr("disabled", "disabled");
				}
			} else {
				$("#personSelect").hide();
			}
		} else {
			$("#personSelect").hide();
		}

		function changValue() {
			$("#project_start_date").val($("#start_date").val());
			$("#project_end_date").val($("#end_date").val());
		}

		function savePsn() {
			//填写检查接口\
			changValue();
			validate($("#fragment-tab1"), "");
			if (!valResult()) {
				irisValShowMsg($("#savePsn"));
				return false;
			}
			
			
			//添加新行
			if (type == "add") {
				addNewRowDeal(parentTable);
				//			parent.countPsnNum('zh_persons,researchs','psncnt_total');
			}

			$("input:not(:radio:button),textarea").each(function() {

				var id = $(this).attr("name");
				var parentObj = null;

				if (id == null || id == "")
					return true;

				//获得父页面的对象
				if (type == "add") {
					parentObj = parentTable.find("tr:last-child").find("[name$='/" + id + "']");
				} else if (type == "edit") {
					parentObj = selectTr.find("[name$='/" + id + "']");

				}

				if (parentObj != null) {
					if (parentObj.is("span")) {
						parentObj.text($(this).val()); //将值写回父页面
					} else {
						parentObj.val($(this).val());
					}
				}

			});

			if (type == "add") {
				parentTable.find("tr:last :radio").attr("checked", true);
				if ("${param.parentTab}" == "zh_persons")
					parent.setSubmitPsn();
			}

			if (submitpsn.length > 0 && submitpsn.val() == "1") {//如果是申报人
				parent.synFzrMsg(0);
				parent.psnSynchro();
			}

			//if(confirm("保存成功，是否返回申请书页面"))
			//	parent.tb_remove();
			//else
			$(".wBox_popup").hide();
			if (confirm("保存成功，是否返回申请书页面")) {
				parent.calDaozhangMoney();
				<security:authorize ifAnyGranted="A_MENU_MANAGE_19">
				parent.$("#depart_code").val($("#depart_code").val());//部门信息
				</security:authorize>
				parent.tb_remove();

			}

			else if (type == "add") {
				type = "edit";
				selectRadio = parentTable.find(":radio:checked"); //父页面选中的单选框
				selectTr = selectRadio.parents("tr"); //父页面选中的行
			}
		}

		$("#savePsn").click(function() {
			if(parseFloat($("#acturalMoney2").val())>parseFloat($("#acturalMoney").val())){
					
				irisValaddMsg(${param.year-1}+"年实际到账金额应小于实际到账总金额");
			}
			setTimeout(savePsn, 100);
		});

		<security:authorize ifAnyGranted="A_MENU_MANAGE_19">
		$("#depart_code").val(parent.$("#depart_code").val());//初始化部门信息
		</security:authorize>

	});

	function tree() {
		// var prof_title_value=$("#prof_title_value").val(); 
		var prof_title_name = $("#prof_title_name").val();
		// var str ="{'id':'"+prof_title_value+"','name':'"+prof_title_name+"'}";
		$("#prof_title").val(prof_title_name);

		var subject_name = $("#subject_name").val();
		// var str ="{'id':'"+prof_title_value+"','name':'"+prof_title_name+"'}";
		$("#subject").val(subject_name);

		var discipline_name = $("#discipline_name").val();
		// var str ="{'id':'"+prof_title_value+"','name':'"+prof_title_name+"'}";
		$("#discipline").val(discipline_name);

	}

	function loadAjaxSelect(selectId, url, params, varParm) {
		$.ajax({
			url : url,
			type : 'post',
			dataType : 'json',
			data : params,
			success : function(data) {

				for ( var i = 0; i < data.length; i++) {
					var value = data[i].id;
					var text = data[i].name;
					$("#" + selectId).append("<option value='"+value+"'>" + text + "</option>");

				}
				if (type == "edit") {//如果是修改，才需要初始化select框的值
					var selectValue = $("[name='" + selectId + "_value']").val();
					$("#" + selectId + " option").each(function(i, obj) {
						if ($(obj).val() == selectValue) {
							setTimeout(function() {
								$(obj).attr("selected", true);
							}, 1);
						}
					});
				}

				setDegree();
			}
		});
	}

	function setDegree() {

		var degreeText = $("#degree").children("option").filter(":selected").text();

		if (degreeText == "博士") {
			$("#degree_country_required").show();
			$("#degree_year_required").show();
			var itemClass = $("#degree_country").attr("class");
			if (itemClass.indexOf("required") == -1)
				$("#degree_country_value").addClass("required");
			$("#degree_year").addClass("required");
		} else {//关闭最高学位验证
			$("#degree_country_required").hide();
			$("#degree_year_required").hide();
			$("#degree_country_value").removeClass("required");
			$("#degree_year").removeClass("required");
		}
	}

	function changeCardType() {
		var cardTypeObj = $("[name='card_type_value']");
		var cardCodeObj = $("[name='card_code']");
		var mobile = $("#mobile");

		if (cardTypeObj.val() == "1") {
			cardCodeObj.addClass("idCard");
			mobile.addClass("mobile");
			//cardCodeObj.attr("label","身份证");
		} else {
			cardCodeObj.removeClass("idCard");
			mobile.removeClass("mobile");
			//cardCodeObj.attr("label","证件号码");
		}
	}

	//选择项目负责人回调
	function selectPsnCall(data) {
		/* $(parent.document).find("input[name$='psn_code']").val(data.person.psnCode);
		$("input[name='zh_name']").val(data.person.zhName);
		var gender_value = "";
		if (data.personExtend.basic_info.gender_value=='F') {
			$("input[name='gender'][value='F']").attr("checked",true);
			gender_value = "F";
		} else { 
			$("input[name='gender'][value='M']").attr("checked",true);
			gender_value = "M";
		}
		$("input[name='gender_value']").val(gender_value);
		$("#card_type").val(data.personExtend.basic_info.card_type_value);
		$("input[name='card_type_value']").val(data.personExtend.basic_info.card_type_value);
		$("input[name='card_type_name']").val(data.personExtend.basic_info.card_type_name);
		$("input[name='card_code']").val(data.personExtend.basic_info.card_code);
		$("#ethnicity").val(data.personExtend.basic_info.ethnicity_value);
		$("input[name='ethnicity_value']").val(data.personExtend.basic_info.ethnicity_value);
		$("input[name='ethnicity_name']").val(data.personExtend.basic_info.ethnicity_name);
		$("#region").val(data.personExtend.basic_info.region_value);
		$("input[name='region_value']").val(data.personExtend.basic_info.region_value);
		$("input[name='region_name']").val(data.personExtend.basic_info.region_name);
		$("#org").val(data.personExtend.basic_info.org_name);
		$("input[name='org_code']").val(data.person.orgCode);
		$("#prof_title").val(data.personExtend.basic_info.prof_title_name);
		$("input[name='prof_title_value']").val(data.personExtend.basic_info.prof_title_value);
		$("input[name='prof_title_name']").val(data.personExtend.basic_info.prof_title_name);
		$("input[name='position']").val(data.personExtend.basic_info.position);
		$("input[name='birthday']").val(data.personExtend.basic_info.birthday);
		$("input[name='tel_work']").val(data.personExtend.contact.tel_work);
		$("#degree").val(data.personExtend.basic_info.degree_value);
		$("input[name='degree_value']").val(data.personExtend.basic_info.degree_value);
		$("input[name='degree_name']").val(data.personExtend.basic_info.degree_name);
		$("#degree_country").val(data.personExtend.basic_info.degree_country_value);
		$("input[name='degree_country_value']").val(data.personExtend.basic_info.degree_country_value);
		$("input[name='degree_country_name']").val(data.personExtend.basic_info.degree_country_name);
		$("input[name='degree_college']").val(data.personExtend.basic_info.degree_college);
		$("input[name='degree_year']").val(data.personExtend.basic_info.degree_year);
		$("#academician").val(data.personExtend.basic_info.academician_value);
		$("input[name='academician_value']").val(data.personExtend.basic_info.academician_value);
		$("input[name='academician_name']").val(data.personExtend.basic_info.academician_name);
		$("#post_doctor").val(data.personExtend.basic_info.post_doctor_value);
		$("input[name='post_doctor_value']").val(data.personExtend.basic_info.post_doctor_value);
		$("input[name='post_doctor_name']").val(data.personExtend.basic_info.post_doctor_name);
		$("input[name='email']").val(data.personExtend.contact.email);
		$("input[name='mobile']").val(data.personExtend.contact.mobile);
		$("#educate").val(data.personExtend.basic_info.educate_value);
		$("input[name='educate_value']").val(data.personExtend.basic_info.educate_value);
		$("input[name='educate_name']").val(data.personExtend.basic_info.educate_name);
		$("input[name='subject_code']").val(data.personExtend.basic_info.subject_code);
		$("input[name='subject_name']").val(data.personExtend.basic_info.subject_name);
		$("input[name='discipline_code']").val(data.personExtend.basic_info.discipline_code);
		$("input[name='discipline_name']").val(data.personExtend.basic_info.discipline_name);
		tree();
		$("input[name='major_work']").val(data.personExtend.contact.major_work);
		
		<security:authorize ifAnyGranted="A_MENU_MANAGE_19">
		$("#depart_code").val(data.person.deptCode);
		</security:authorize>
		 */
		tb_remove2();
	}
</script>
<script type="text/javascript">
	function initTreeValueExt(treeId, treeNode) {

		if (!(treeNode && (treeNode.level > 0 || !treeNode.isParent))) {
			scmWarn($("#" + treeId).attr("label") + messageTip.researchAreaInvalidDisciplineCode);
			if (treeNode.level == 0) {
				$("#" + treeId).val("");
				$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId + "_code']").val("");
				$("#" + treeId).parents("td").find("[name$='" + treeId + "_value'],[id$='" + treeId + "_value']").val("");
				$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId + "_name']").val("");
			}

			return false;
		}

		var str = treeNode.name;
		var obj = treeNode.parentNode;
		while (obj != null) {
			obj = obj.parentNode;
		}

		$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId + "_code']").val(treeNode.id);
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_value'],[id$='" + treeId + "_value']").val(treeNode.id);
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId + "_name']").val(str);

	}
	function giveValue(value) {
		$("#trade_type").val(value);
	}
</script>
</head>
<body>

	<div id="tabnav">
		<ul>
			<li class="down" id="tab1" onclick="changeTab(this.id)">
				<a href="###">
					<span>成果信息</span>
				</a>
			</li>
		</ul>
	</div>

	<div class="tab_box" id="fragment-tab1">
		<table class="t_css" width="100%" border="0" cellpadding="0"
			label="成果信息" cellspacing="1">
			<col style="width:25%"/>
			<col style="width:25%"/>
			<col style="width:25%"/>
			<col style="width:25%"/>
			<tr>
				<td nowrap align="right">
					<span class="color_red">*</span>
					技术合同项目名称：
				</td>
				<td width="350px">
					<input name="project_name" label="技术合同项目名称" type="text" required
						class="input_text required maxlength:100" value="" maxlength="100" />
				</td>

				<td nowrap align="right">
					<span class="color_red">*</span>
					技术合同网上登记号：
				</td>
				<td width="350px">
					<input name="project_code" label="技术合同网上登记号" type="text" required
						class="input_text required" value="" />
				</td>
			</tr>
			<tr>
				<td nowrap align="right">
					<span class="color_red">*</span>
					合同开始日期：
				</td>
				<td>
					<cpt:date id="start_date" value=""
						className="required date beforeToday dateCompare:end_date" label="合同开始日期"
						name="start_date"></cpt:date>
					<input type="hidden" name="project_start_date"
						id="project_start_date" label="合同开始日期" class=" " />
				</td>
				<td nowrap align="right">
					<span class="color_red">*</span>
					合同结束日期：
				</td>
				<td>
					<cpt:date id="end_date" value=""
						className="required" label="合同结束日期"
						name="end_date"></cpt:date>
					<input type="hidden" name="project_end_date" id="project_end_date"
						label="合同结束日期" class="" />
				</td>
			</tr>
			<tr>
				<td nowrap align="right">
					<span class="color_red">*</span>
					技术合同交易类别（单选）：
				</td>
				<td colspan="3">
					<input type="radio" id="type_1" name="type" label="技术合同交易类别"
						value="技术开发" class="do"
						onclick="initControlValue(this.id);giveValue(this.value)" />
					技术开发 &nbsp;&nbsp;&nbsp;&nbsp;
					<input type="radio" id="type_2" name="type" value="技术转让" class="do"
						onclick="initControlValue(this.id);giveValue(this.value)" />
					技术转让&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="radio" id="type_3" name="type" value="技术服务" class="do"
						onclick="initControlValue(this.id);giveValue(this.value)" />
					技术服务
					<input type="hidden" name="trade_type" id="trade_type"
						label="技术合同交易类别" class="required" />
				</td>
			</tr>
			<tr>
				<td align="right">
					<span class="color_red">*</span>
					买方企业名称：
				</td>
				<td width="350px">
					<input name="buyer_name" label="买方企业名称" type="text" required
						class="input_text required" value="" />
				</td>
				<td align="right">
					<span class="color_red">*</span>
					买方所在市：
				</td>
				<td width="350px">
					<input name="buyer_city" label="买方所在市" type="text" required
						class="input_text required" value="" />
				</td>
			</tr>
			<tr>
				<td align="right">
					<span class="color_red">*</span>
					技术合同总金额（万元）：
				</td>
				<td width="350px">
					<input name="project_sum" label="技术合同总金额" type="text" required
						class="input_text required" value="" style="text-align:right"
						onfocus="InitInput.setNumber(this,7,4,2);" />
				</td>
				<td align="right">
					<span class="color_red">*</span>
					实际到账总金额（万元）：
				</td>
				<td width="350px">
					<input name="actural_sum" label="实际到账总金额" type="text" required id="acturalMoney"
						class="input_text required" value="" style="text-align:right"
						onfocus="InitInput.setNumber(this,7,4,2);"/>
				</td>
			</tr>
			<tr>
				<td align="right">
					<span class="color_red">*</span>
					其中：${param.year-1}年实际到账金额（以开据发票为准）：
				</td>
				<td width="350px">
					<input name="actural2_sum" label="${param.year-1}年实际到账金额" type="text" required
						class="input_text required" value="" style="text-align:right" id="acturalMoney2"
						onfocus="InitInput.setNumber(this,7,4,2);"/>
				</td>
				<td align="right">
					<span class="color_red">*</span>
					拉动企业研发投入（万元）：
				</td>
				<td width="350px">
					<input name="comp_inverst" label="拉动企业研发投入" type="text" required
						class="input_text required" value="" style="text-align:right"
						onfocus="InitInput.setNumber(this,7,4,2);" />
				</td>
			</tr>
			<tr>
				<td align="right">
					<span class="color_red">*</span>
					预计带动企业新增产值（万元）：
				</td>
				<td width="350px">
					<input name="comp_profit" label="预计带动企业新增产值" type="text" required
						class="input_text required" value="" style="text-align:right"
						onfocus="InitInput.setNumber(this,7,4,2);" />
				</td>
			</tr>
			<tr>
				<td align="right">
					<span class="color_red">*</span>
					成果转化收益奖励个人或团队：
				</td>
				<td colspan="3">
					共奖励
					<input name="award_person_num1" label="金钱奖励人数" type="text" required
						class="input_text required" style="width: 78px" value="" onfocus="InitInput.setNumber(this,7,0,0)"/>
					人
					<input name="award_money" label="奖励金额" type="text" required style="text-align:right;width: 98px"
						class="input_text required" value="" onfocus="InitInput.setNumber(this,7,4,2)"/>
					万元（或股权奖励
					<input name="award_person_num2" label="股权奖励奖励人数" type="text"
						required class="input_text required" style="width: 78px" value="" onfocus="InitInput.setNumber(this,7,0,0)"/>
					人
					<input name="award_stock" label="奖励股权数" type="text" required
						class="input_text required" style="width: 98px" value="" value="" onfocus="InitInput.setNumber(this,7,0,0)"/>
					股）
				</td>
			</tr>
			<tr>
				<td align="right" rowspan="3">
					<span class="color_red">*</span>
					技术成果转移、转化和产业化情况（限200字）：
				</td>
				<td colspan="3">
					<textarea style="width:600px; height:100px" id="change_result" 
						label="技术成果转移、转化和产业化情况" class="input_text required"  
						name="change_result"></textarea>
				</td>
			</tr>
		</table>
	</div>


	<!-- 
		<div class="tab_box" id="fragment-tab4" style="display: none">
		</div>
	 -->
	<table width="100%" align="center">
		<tr>
			<td>
				<input type="button" class="button_01 notdisabled" id="savePsn"
					value="保存">
				&nbsp;
				<input type="button" id="cancel" class="button_01 notdisabled"
					value="取消" onclick="parent.tb_remove();">
			</td>
		</tr>
	</table>
	<br />
</body>
</html>